This allows better proportional view of upright images related to landscape images on a page without nailing the width of upright images to a fix value which makes views for anon unproportional and user preferences useless
Usage:
* [[Image:pix.jpg|thumb|upright|caption]] = Upright image will be scaled down by $wgThumbUpright (default 0.75, seems to me the best value)
* [[Image:pix.jpg|thumb|upright=0.6|caption]] = Upright image will be scaled down by 0.6
Size of thumb is always rounded to full __0 px to avoid odd thumbsizes and spare the cache
If used in combination with a width, upright will be ignored.
it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
== Configuration changes since 1.10 ==
+* $wgThumbUpright - Adjust width of upright images when parameter 'upright' is
+ used
== New features since 1.10 ==
* (bug 9628) Show warnings about slave lag on Special:Contributions,
Special:Watchlist
* (bug 8818) Expose "wpDestFile" as parameter $1 to "uploaddisabledtext"
+* Introducing new image parameter 'upright' and corresponding variable
+ $wgThumbUpright. This allows better proportional view of upright images
+ related to landscape images on a page without nailing the width of upright
+ images to a fix value which makes views for anon unproportional and user
+ preferences useless
== Bugfixes since 1.10 ==
300
);
+/**
+ * Adjust width of upright images when parameter 'upright' is used
+ * This allows a nicer look for upright images without the need to fix the width
+ * by hardcoded px in wiki sourcecode.
+ */
+$wgThumbUpright = 0.75;
+
/**
* On category pages, show thumbnail gallery for images belonging to that
* category instead of listing them as articles.
/** @todo document */
function makeImageLinkObj( $nt, $label, $alt, $align = '', $params = array(), $framed = false,
- $thumb = false, $manual_thumb = '', $valign = '' )
+ $thumb = false, $manual_thumb = '', $valign = '', $upright = false, $upright_factor = 0 )
{
- global $wgContLang, $wgUser, $wgThumbLimits;
+ global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright;
$img = new Image( $nt );
$wopt = User::getDefaultOption( 'thumbsize' );
}
- $params['width'] = min( $params['width'], $wgThumbLimits[$wopt] );
+ // Reduce width for upright images when parameter 'upright' is used
+ if ( $upright_factor == 0 ) {
+ $upright_factor = $wgThumbUpright;
+ }
+ // Use width which is smaller: real image width or user preference width
+ // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
+ $params['width'] = min( $params['width'], $upright ? round( $wgThumbLimits[$wopt] * $upright_factor, -1 ) : $wgThumbLimits[$wopt] );
}
}
if ( $align == '' ) {
$align = $wgContLang->isRTL() ? 'left' : 'right';
}
- return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb ).$postfix;
+ return $prefix.$this->makeThumbLinkObj( $img, $label, $alt, $align, $params, $framed, $manual_thumb, $upright ).$postfix;
}
if ( $params['width'] && $img->exists() ) {
* Make HTML for a thumbnail including image, border and caption
* $img is an Image object
*/
- function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "" ) {
+ function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $params = array(), $framed=false , $manual_thumb = "", $upright = false ) {
global $wgStylePath, $wgContLang;
$page = isset( $params['page'] ) ? $params['page'] : false;
if ( empty( $params['width'] ) ) {
- $params['width'] = 180;
+ // Reduce width for upright images when parameter 'upright' is used
+ $params['width'] = $upright ? 130 : 180;
}
$thumb = false;
if ( $manual_thumb != '' ) {
# * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
# * center center the image
# * framed Keep original image size, no magnify-button.
+ # * upright reduce width for upright images, rounded to full __0 px
# vertical-align values (no % or length right now):
# * baseline
# * sub
$mwManualThumb =& MagicWord::get( 'img_manualthumb' );
$mwWidth =& MagicWord::get( 'img_width' );
$mwFramed =& MagicWord::get( 'img_framed' );
+ $mwUpright =& MagicWord::get( 'img_upright' );
$mwPage =& MagicWord::get( 'img_page' );
$caption = '';
$params = array();
$framed = $thumb = false;
+ $upright = false;
+ $upright_factor = 0;
$manual_thumb = '' ;
$align = $valign = '';
$sk = $this->mOptions->getSkin();
foreach( $part as $val ) {
if ( !is_null( $mwThumb->matchVariableStartToEnd($val) ) ) {
$thumb=true;
+ } elseif ( !is_null( $match = $mwUpright->matchVariableStartToEnd( $val ) ) ) {
+ $upright = true;
+ $upright_factor = floatval( $match );
} elseif ( ! is_null( $match = $mwManualThumb->matchVariableStartToEnd($val) ) ) {
# use manually specified thumbnail
$thumb=true;
$alt = Sanitizer::stripAllTags( $alt );
# Linker does the rest
- return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign );
+ return $sk->makeImageLinkObj( $nt, $caption, $alt, $align, $params, $framed, $thumb, $manual_thumb, $valign, $upright, $upright_factor );
}
/**
'img_center' => array( 1, 'center', 'centre' ),
'img_framed' => array( 1, 'framed', 'enframed', 'frame' ),
'img_page' => array( 1, 'page=$1', 'page $1' ),
+ 'img_upright' => array( 1, 'upright', 'upright=$1', 'upright $1' ),
'img_baseline' => array( 1, 'baseline' ),
'img_sub' => array( 1, 'sub' ),
'img_super' => array( 1, 'super', 'sup' ),